﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Audio;
namespace PoolGame2.Assets
{
    public enum SoundEffectType
    {
        CUE_HITS_BALL, 
        BALL_HITS_BALL,
        POCKET_BALL,        
        BALL_HITS_CUSHION,
        BAD_SHOT,
        GOOD_SHOT,
        START_GAME,
        WIN_GAME,
        LOSE_GAME,
    };

    public class AudioDatabase
    {
        private AudioEngine engine;
        private WaveBank waveBank;
        private SoundBank soundBank;

        public AudioDatabase() 
        {            
            engine = new AudioEngine("Content/sounds/sound.xgs");
            waveBank = new WaveBank(engine, "Content/sounds/sound_wave.xwb");
            soundBank = new SoundBank(engine, "Content/sounds/sound_sound.xsb");
        }

        private Cue Playsound(string name)
        {
            Cue cue = soundBank.GetCue(name);
            cue.Play();

            return cue;
        }
        

        public void Update()
        {
            engine.Update();
        }
        /*

         */
        public void PlaySoundEffect(SoundEffectType soundEffect)
        {
            switch (soundEffect)
            {         
                case SoundEffectType.CUE_HITS_BALL:
                    Playsound("CUE_HITS_BALL");
                    break;
                case SoundEffectType.BALL_HITS_BALL:
                    Playsound("BALL_HITS_BALL");
                    break;
                case SoundEffectType.POCKET_BALL:
                    Playsound("POCKET_BALL");
                    break;
                case SoundEffectType.BALL_HITS_CUSHION:
                    Playsound("BALL_HITS_CUSHION");
                    break;
                case SoundEffectType.WIN_GAME:
                    Playsound("WIN_GAME");
                    break;
                case SoundEffectType.GOOD_SHOT:
                    Playsound("GOOD_SHOT");
                    break;
                case SoundEffectType.BAD_SHOT:
                    Playsound("BAD_SHOT");
                    break;  
                case SoundEffectType.LOSE_GAME:
                    Playsound("LOSE_GAME");
                    break;
                case SoundEffectType.START_GAME:
                    Playsound("START_GAME");
                    break;
            }
        }
    }
}
